package com.ts.api.module.match.market.internal.wrapper.context;

import com.ts.api.module.api.convert.core.annotation.ApiConsumerMarketConvertType;
import com.ts.api.module.match.core.MatchRegisterContext;
import com.ts.api.module.match.market.internal.wrapper.MarketDataExchangeIpWrapper;
import com.ts.api.module.match.market.internal.wrapper.MarketDataExchangeMd5Wrapper;
import com.ts.api.module.match.market.internal.wrapper.MarketDataExchangePhoneMaskWrapper;
import com.ts.api.module.match.market.internal.wrapper.MarketDataExchangeUserFormWrapper;
import com.ts.api.module.match.market.internal.wrapper.MarketDataExchangeWrapper;
import org.springframework.stereotype.Component;

/**
 *  贷超-撞库包装器上下文
 *
 *  @author Pan
 */
@Component
public class MarketDataExchangeWrapperContext extends MatchRegisterContext<ApiConsumerMarketConvertType, MarketDataExchangeWrapper> {

    /**
     *  初始化构造函数
     *  @author Pan
     */
    public MarketDataExchangeWrapperContext() {
        super(ApiConsumerMarketConvertType.class);
        register(ApiConsumerMarketConvertType.DATA_EXCHANGE_MD5,            MarketDataExchangeMd5Wrapper.class);
        register(ApiConsumerMarketConvertType.DATA_EXCHANGE_PHONE_MASK_8,   MarketDataExchangePhoneMaskWrapper.class);
        register(ApiConsumerMarketConvertType.DATA_EXCHANGE_PHONE_MASK_9,   MarketDataExchangePhoneMaskWrapper.class);
        register(ApiConsumerMarketConvertType.DATA_EXCHANGE_PHONE_MASK_10,  MarketDataExchangePhoneMaskWrapper.class);
        register(ApiConsumerMarketConvertType.DATA_EXCHANGE_IP,             MarketDataExchangeIpWrapper.class);
        register(ApiConsumerMarketConvertType.DATA_EXCHANGE_USER_FORM,      MarketDataExchangeUserFormWrapper.class);
    }

    @Override
    public MarketDataExchangeWrapper getContext(ApiConsumerMarketConvertType e) {
        return super.getContext(e);
    }

    /**
     *  通过贷超撞库类型获取wrapper
     *
     *  @author Pan
     *  @param  apiDataExchangeType     撞库类型
     *  @return MarketDataExchangeWrapper
     */
    public MarketDataExchangeWrapper getContext(Integer apiDataExchangeType) {
        ApiConsumerMarketConvertType apiConsumerMarketConvertType = ApiConsumerMarketConvertType.getDataExchangeEnum(apiDataExchangeType);
        return getContext(apiConsumerMarketConvertType);
    }
}
